﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using ESOL.Common.Entity;

namespace ESOL.Services
{
    [ServiceContract]
    public interface IPurService
    {
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        bool TestConnect();

        //供应商
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        MstSupplierEntity AddPurSupplier(MstSupplierEntity supp);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        MstSupplierEntity UpdatePurSupplier(MstSupplierEntity supp);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? DelPurSupplier(MstSupplierEntity supp);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? SavePurSupplier(SupplierSaveParam param);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        List<MstSupplierAttachedEntity> UploadPurSupplierAtt(List<AttachUploadMessage> source);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? DelPurSupplierContact(MstSupplierContactEntity contact);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? DelPurSupplierAtt(MstSupplierAttachedEntity att);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        MstSupplierEntity GetPurSupplierByKey(string supplierId);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        List<MstSupplierContactEntity> GetPurSupplierContactAllListBySuppId(string supplierId);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        List<MstSupplierAttachedEntity> GetPurSupplierAttAllListBySuppId(string supplierId);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        SupplierQueryPageResult GetPurSupplierAllListByCondition(SupplierQueryCondition con);

        //采购申请：工作流
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurAppEntity AddPurApp(PurAppEntity app);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurAppEntity UpdatePurApp(PurAppEntity app);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurAppEntity UpdatePurAppAndItem(PurAppEntity app, List<PurAppItemEntity> appItems);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? DelPurApp(PurAppEntity app);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? DelPurAppItem(PurAppItemEntity appItem);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? SavePurApp(string userNo, PurAppEntity app, List<PurAppItemEntity> items);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurAppEntity GetPurAppByKey(string purAppId);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        List<PurAppItemEntity> GetPurAppItemByAppId(string purAppId);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurAppQueryPageResult GetPurAppByCondition(AppQueryCondition con);

        //采购明细计划
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurAppItemQueryPageResult GetPurAppItemAllListByCondition(PurAppItemQueryCondition con);

        //采购询价单
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        MergePurAppItemResult MergePurAppItem(List<PurMaintainAppItem> items);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurRfqEntity AddPurRfq(PurRfqEntity rfq);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurRfqEntity UpdatePurRfq(PurRfqEntity rfq);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? DelPurRfq(PurRfqEntity rfq);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? DelPurRfqItem(PurRfqItemEntity item);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? SavePurRfq(PurRfqEntity rfq, List<PurRfqItemEntity> items, List<PurRlAppiRfqiEntity> rels);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurRfqEntity GetPurMaintainRfqByKey(string purRfqId);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        List<PurRfqItemEntity> GetPurRfqItemByRfqNo(string rfqNo);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurRfqQueryPageResult GetPurRfqAllListByCondition(RfqQueryCondition con);

        //采购报价单
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurQuotationEntity AddPurQu(PurQuotationEntity qu);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurQuotationEntity UpdatePurQu(PurQuotationEntity qu);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? DelPurQu(PurQuotationEntity qu);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? SavePurQu(PurQuotationEntity qu, List<PurQuotationItemEntity> items);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurQuotationEntity GetPurMaintainQuByKey(string puuQuId);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        QuQueryPageResult GetPurMaintainQuByCondition(QuQueryCondition con);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        List<PurQuotationItemEntity> GetPurMaintainQuItemAllListByQuNo(string quNo);

        //采购订单：工作流

        /// <summary>
        /// 根据采购申请明细，产生采购订单
        /// 回写采购申请明细status为：已下单
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        TransPurAppItemResult CreatePurPoByApp(List<PurMaintainAppItem> items);

        /// <summary>
        /// 根据采购报检单，产生采购订单
        /// 回写采购申请明细status为：已下单
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        TransPurAppItemResult CreatePurPoByQu(List<PurQuotationEntity> qus);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurPoEntity AddPurPo(PurPoEntity po);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurPoEntity UpdatePurPo(PurPoEntity po);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurPoEntity WfEndUpdatePurPo(PurPoEntity po);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? DelPurPo(PurPoEntity po);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? SavePurPo(PurPoEntity po, List<PurPoItemEntity> items);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? AddPurPoForApp(PurPoEntity po, List<PurPoItemEntity> items, List<PurRlAppiPoiEntity> rels);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? AddPurPoForQu(PurPoEntity po, List<PurPoItemEntity> items, List<PurRlQuiPoiEntity> rels);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? AddPurPoForCustom(PurPoEntity po, List<PurPoItemEntity> items);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? DelPurPoItem(PurPoItemEntity item);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurPoEntity GetPurMaintainPoByKey(string purPoId);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PoQueryPageResult GetPurMaintainPoByCondition(PoQueryCondition con);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurPoItemEntity GetPurMaintainPoItemByKey(string purPoItemId);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        List<PurPoItemEntity> GetPurMaintainPoItemAllListByPoNo(string poNo);

        //采购到货计划
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        TransPurPoResult CreatePurArvByPo(PurPoEntity po);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        List<PurArvEntity> CreatePurArvsByPo(List<PurPoEntity> pos);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurArvEntity AddPurArv(string userNo, PurArvEntity arv);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurArvEntity UpdatePurArv(string userNo, PurArvEntity arv);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? DelPurMaintainArv(PurArvEntity arv);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? DelPurMaintainArvItem(PurArvItemEntity item);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? AddPurMaintainArv(PurArvEntity arv, List<PurArvItemEntity> items);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? SavePurMaintainArv(PurArvEntity arv, List<PurArvItemEntity> items);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurArvEntity GetPurMaintainArvByKey(string id);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurArvQueryPageResult GetPurMaintainArvByCondition(PurArvQueryCondition con);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurArvItemEntity GetPurMaintainArvItemByKey(string id);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        List<PurArvItemEntity> GetPurMaintainArvItemAllListByArvNo(string arvNo);

        //采购退货单：工作流
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? AddPurRo(string userNo, PurRoEntity ro);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? UpdatePurRo(string userNo, PurRoEntity ro);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? DelPurRo(PurRoEntity ro);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        int? SavePurRo(PurRoSaveParam param);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurRoPageResult GetPurRoAllListByCondition(PurRoQueryCondition con);

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurRoEntity GetPurRoByKey(string roId);

        //PurRoItem 采购退货单明细
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        List<PurRoItemDto> GetRoItemDtoAllListByRoId(string roId);

        //PurPoItem 采购单明细
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurPoItemPageResult GetPoItemAllListByCondition(PurPoItemQueryCondition param);

        //供应商范围
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        List<MstSupplierScopeEntity> GetPurSupplierScopeAllListBySupplierId(string supplierId);

        //工作流：采购到货-质检
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        List<QcIqcEntity> PurArvToQcIqc(string userNo, PurArvEntity arv);

        //采购到货-入库
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        InvIappEntity PurArvToInvIapp(string userNo, PurArvEntity arv);

        //采购退货-出库申请
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        InvOappEntity PurRoToInvOapp(string userNo,PurRoEntity ro);

        //查询采购汇总数据
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurSupplierSummeryPageResult GetPurSupplierSummary(SupplierQueryCondition con);

        //查询采购业务清单
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        PurBusinessListDtoPageResult GetPurBusinessList(PurBusinessListQueryCondition con);

        //采购订单的到货数和入库数
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        DTODataTable GetPOArvAndStockInDetail();

        //没转化成采购订单的请购单数。
        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        DTODataTable GetPRNotToPo();

        [OperationContract]
        [FaultContract(typeof(ProcessExecutionFault))]
        DTOBool CreatePRByPO(PurAppEntity pr, List<PurAppItemEntity> prItem);

    }
}
